/-boot
/-docs
/-editor
CodeMirrorEditor.ts
CompletionCodeMirrorEditor.ts
CssEditorType.ts
Editor.ts
EditorType.ts
HtmlEditorType.ts
JavaScriptEditorType.ts
TypeScriptEditorType.ts
x-last-PlainTextEditorType.ts
/-files
/-files-old
/-imports
/-layout
/-shell
/-storage
/-tests
/-typings
codemirror.d.ts
knockout.d.ts
typescriptServices.d.ts
websql.d.ts
zip.js.d.ts
Dom.ts
TypeScriptService.ts
functions.ts
ko.ts
nteapo.html
persistence.api.ts
persistence.ts
shell.ts
teapo.html
teapo.js
teapo.ts
try.html
try.js
xxxxxxxxxx
 
209
    export interface Script {
210
​
211
      /**
212
       * Whole text of the file as a single string.
213
       */
214
      text(): string;
215
​
216
      /**
217
       * History of changes to the file, in a form of objects expected by TypeScript
218
       * (basically, offset, old length, new length).
219
       */
220
      changes(): TypeScript.TextChangeRange[];
221
​
222
      /**
223
       * Used internally, don't ever change.
224
       */
225
      _cachedSnapshot: TypeScript.IScriptSnapshot;
226
    }
227
  }
228
​
229
  class TypeScriptDocumentSnapshot implements TypeScript.IScriptSnapshot {
230
    version = 0;
231
    private _text: string = null;
232
​
233
    constructor(public scriptData: TypeScriptService.Script) {
234
      if (this.scriptData.changes)
235
        this.version = this.scriptData.changes().length;
236
    }
237
​
238
    getText(start: number, end: number): string {
239
      var text = this._getText();
240
      var result = text.slice(start, end);
241
      return result;
242
    }
243
​
244
    getLength(): number {
245
      var text = this._getText();
246
      return text.length;
247
    }
248
​
249
    getLineStartPositions(): number[] {
250
      var text = this._getText();
251
      var result = TypeScript.TextUtilities.parseLineStarts(text);
252
      return result;
253
    }
254
    
255
    getChangeRange(oldSnapshot: TypeScript.IScriptSnapshot): TypeScript.TextChangeRange {
256
      var baseVersion = (<any>oldSnapshot).version || 0;
257
      return this.getTextChangeRangeSinceVersion(baseVersion);
258
    }
259
​
260
    getTextChangeRangeSinceVersion(scriptVersion: number): TypeScript.TextChangeRange {
261
      if (!this.scriptData.changes)
262
        return TypeScript.TextChangeRange.unchanged;
263
​
264
      // TODO: check that we are not called for changes on old snapshots
265
​
266
      var chunk = this.scriptData.changes().slice(scriptVersion);
267
​
268
      var result = TypeScript.TextChangeRange.collapseChangesAcrossMultipleVersions(chunk);
269
      return result;
270
    }
271
​
272
    private _getText() {
273
      if (!this._text)
274
        this._text = this.scriptData.text ? this.scriptData.text() : <string><any>this.scriptData;
275
      return this._text;
276
    }
277
  }
278
}
254:43 interface unknown